<?php
/*
                           _
                           \"-._ _.--"~~"--._
                            \   "            ^.    ___
                            /                  \.-~_.-~
                     .-----'     /\/"\ /~-._      /
                    /  __      _/\-.__\L_.-/\     "-.
                   /.-"  \    ( ` \_o>"<o_/  \  .--._\
                  /'      \    \:     "     :/_/     "`
                          /  /\ "\    ~    /~"
                          \ I  \/]"-._ _.-"[
                       ___ \|___/ ./    l   \___   ___
                  .--v~   "v` ( `-.__   __.-' ) ~v"   ~v--.
               .-{   |     :   \_    "~"    _/   :     |   }-.
              /   \  |           ~-.,___,.-~           |  /   \
             ]     \ |                                 | /     [
             /\     \|     :                     :     |/     /\
            /  ^._  _K.___,^                     ^.___,K_  _.^  \
           /   /  "~/  "\                           /"  \~"  \   \
          /   /    /     \ _          :          _ /     \    \   \
        .^--./    /       Y___________l___________Y       \    \.--^.
        [    \   /        |        [/    ]        |        \   /    ]
        |     "v"         l________[____/]________j         }r"     /
        }------t          /                       \       /`-.     /
        |      |         Y                         Y     /    "-._/
        }-----v'         |         :               |     7-.     /
        |   |_|          |         l               |    / . "-._/
        l  .[_]          :          \              :  r[]/_.  /
         \_____]                     "--.             "-.____/




        */
/**
 * Created by PhpStorm.
 * User: hengge
 * Date: 2018/6/2
 * Time: 15:07
 */
namespace app\admin\controller;



use think\Controller;
use think\Request;
use think\Session;

class Common extends Controller {
    protected $controller_name;
    protected $model_data;  //获取当前model数据信息
    public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
        //检查是否自动安装
        if(!file_exists(APP_PATH.'install.lock')){
            $this->redirect(url('/install/index'));
        }

        //登录检测
        if(!Session::has('admin.username')){
            $this->redirect('Login/index');
        }
        $this->setting=model('setting')->getSetting();
        $this->assign('setting',$this->setting);

        $request= Request::instance();
        $this->controller_name=strtolower($request->controller());
        //根据当前controller获取模型数据
        $this->model_data=model('models')->adminGetModelDataToTableName(strtolower($request->controller()));

        /*if($this->model_data===false){
            $this->error('数据出错');
        }*/
    }
}